package logic

import (
	"context"
	"technician_srv/model/mysql"

	"technician_srv/internal/svc"
	"technician_srv/technician"

	"github.com/zeromicro/go-zero/core/logx"
)

type InsertOrderLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewInsertOrderLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InsertOrderLogic {
	return &InsertOrderLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *InsertOrderLogic) InsertOrder(in *technician.InsertOrderRequest) (*technician.InsertOrderResponse, error) {
	// todo: add your logic here and delete this line
	order := mysql.Order{
		TechnicianId: int(in.TechnicianId),
		WorkId:       int(in.WorkId),
		Price:        int(in.Price),
		OrderNum:     in.OrderNum,
	}

	err := order.InsertOrder()
	if err != nil {
		return nil, err
	}

	return &technician.InsertOrderResponse{}, nil
}
